package clothes.tools.service.impl;

import clothes.tools.dao.CustomerDao;
import clothes.tools.dao.impl.CustomerDaoImpl;
import clothes.tools.pojo.Customer;
import clothes.tools.service.CustomerService;

import java.util.List;

public class CustomerServiceImp implements CustomerService {
    private CustomerDao customerDao=new CustomerDaoImpl();
    @Override
    public void ResistCustomer(Customer customer) {
        customerDao.saveUser(customer);
    }

    @Override
    public Customer login(Customer customer) {
        return customerDao.queryByUsernameAndPassword(customer.getCid(),customer.getMima());
    }

    @Override
    public boolean existsUsername(String username) {
        if(customerDao.queryByUsername(username)==null){
            //等于null，说明没查到，没查到说明用户名可用
            return false;
        }
        else
        return true;
    }

    @Override
    public void deleteById(String id) {
        customerDao.deleteById(id);
    }

    @Override
    public void updateCustomer(Customer customer) {
        customerDao.updateCustomer(customer);
    }

    @Override
    public List<Customer> queryCustomer() {
        return customerDao.queryCustomer();
    }

    @Override
    public List<Customer> queryCustomer(String page, String limit) {
        return customerDao.queryCustomer(page, limit);
    }

    @Override
    public List<Customer> queryCustomers(String page, String limit, String name) {
        return customerDao.queryCustomers(page, limit, name);
    }
}
